import { useAppDispatch, useAppSelector } from "@/store/hooks";
import {
  changeModal,
  getWhiteAuditAsync,
} from "@/store/whiteAudit/whiteAuditSlice";
import { Button, Card, Space } from "antd";
import type { ReactElement } from "react";

export default function Filter(): ReactElement<typeof Card, "div"> {
  const { params, table } = useAppSelector((state) => state.whiteAudit);
  const dispatch = useAppDispatch();
  return (
    <Card>
      <Space
        wrap
        size="large"
        className="w-full flex justify-between"
        classNames={{ item: "last:ml-auto" }}
      >
        <Button
          type="primary"
          ghost
          onClick={() => dispatch(changeModal({ open: true }))}
        >
          创建
        </Button>
        <Button
          loading={table.status === "loading"}
          type="primary"
          onClick={(): void => {
            dispatch(getWhiteAuditAsync({...params}));
          }}
        >
          查询
        </Button>
      </Space>
    </Card>
  );
}
